/**
 * Copyright 2007 American Well Systems
 * All rights reserved.
 *
 * It is illegal to use, reproduce or distribute
 * any part of this Intellectual Property without
 * prior written authorization from American Well.
 */
package org.rich.charlesmurphy.core.filters;

import org.ddevil.data.Data;
import org.ddevil.data.Filter;

/**
 * Filters out items that that don't match a hostname.
 * @author Rich O'Connell
 */
public class HostnameFilter implements Filter<Data> {
	private String attributeId;
	private String host;

	/**
	 * @param attributeId the attribute id to check
	 * @param hostname the hostname that must be present
	 */
	public HostnameFilter(String attributeId, String hostname) {
		this.host = hostname;
		this.attributeId = attributeId;
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean accept(Data object) {
		String v = (String)object.getValue(attributeId);
		return v.startsWith("https://" + host) || v.startsWith("http://" + host);
	}
}
